//
//  BCOrderWaitCollectionViewCell.m
//  BangcaiSale
//
//  Created by Liang Zhang on 16/7/8.
//  Copyright © 2016年 Bangcai. All rights reserved.
//

#import "BCOrderWaitCollectionViewCell.h"

@implementation BCOrderWaitCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    _backgroudView.layer.cornerRadius = 3.f;
    
    //临时数据 货品：芥蓝、西蓝花等15种商品
    NSMutableString *stuffName = [NSMutableString stringWithCapacity:0];
    NSArray *stuffNameArray = @[@"芥蓝",@"西蓝花"];
    [stuffNameArray enumerateObjectsUsingBlock:^(NSString *stuff, NSUInteger idx, BOOL * _Nonnull stop) {
        [stuffName appendString:stuff];
        if (idx<(stuffNameArray.count-1)) {
            [stuffName appendString:@"、"];
        }
    }];
    NSString *stuffCount = @"15";
    
    NSMutableAttributedString *stuffAttributedString = [[NSMutableAttributedString alloc] initWithString:self.stuffLable.text];
    UIColor *textColor_red = [UIColor colorWithRed:0.933 green:0.310 blue:0.247 alpha:1.000];
    NSString *stuffNameString = [NSString stringWithFormat:@"货品：%@等",stuffName];
    [stuffAttributedString addAttribute:NSForegroundColorAttributeName  //文字颜色
                             value:[UIColor darkGrayColor]
                             range:NSMakeRange(0, stuffNameString.length)];
    [stuffAttributedString addAttribute:NSForegroundColorAttributeName  //文字颜色
                             value:textColor_red
                             range:NSMakeRange(stuffNameString.length, stuffCount.length)];
    [stuffAttributedString addAttribute:NSForegroundColorAttributeName  //文字颜色
                             value:[UIColor darkGrayColor]
                             range:NSMakeRange(stuffNameString.length+stuffCount.length, @"种商品".length)];
    self.stuffLable.attributedText = stuffAttributedString;
    
    NSMutableAttributedString *waitTitleAttributedString = [[NSMutableAttributedString alloc] initWithString:self.sendTimeLable.text];
    UIColor *textColor_blue = [UIColor colorWithRed:0.255 green:0.518 blue:0.984 alpha:1.000];
    NSString *titleString = @"距离发货时间：";
    [waitTitleAttributedString addAttribute:NSForegroundColorAttributeName  //文字颜色
                                      value:[UIColor darkTextColor]
                                      range:NSMakeRange(0, titleString.length)];
    [waitTitleAttributedString addAttribute:NSForegroundColorAttributeName  //文字颜色
                                      value:textColor_blue
                                      range:NSMakeRange(titleString.length, (self.sendTimeLable.text.length-titleString.length))];
    self.sendTimeLable.attributedText = waitTitleAttributedString;
}

+ (instancetype)cellWithCollectionView:(UICollectionView *)collectionView {
    static NSString *ID = @"OrderWaitCellIdentifer";
    UINib *nib = [UINib nibWithNibName:@"BCOrderWaitCollectionViewCell" bundle: [NSBundle mainBundle]];
    [collectionView registerNib:nib forCellWithReuseIdentifier:ID];
    BCOrderWaitCollectionViewCell *cell = [[BCOrderWaitCollectionViewCell alloc] init];
    return cell;
}

@end
